package com.zg.autoflow.web;

import com.zg.autoflow.req.AutoflowInherentGroupAddReq;
import com.zg.autoflow.req.AutoflowInherentGroupIdsReq;
import com.zg.autoflow.service.AutoflowInherentGroupService;
import com.zg.common.core.R;
import com.zg.common.core.dao.Inherent.AutoflowInherentGroup;
import com.zg.common.core.dao.Inherent.dao.AutoflowInherentGroupDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
* @author zg
*/
@RestController
@RequiredArgsConstructor
@Api(tags = {"固有字段分组"})
public class AutoflowInherentGroupController {
	private final AutoflowInherentGroupDao autoflowInherentGroupDao;
	private final AutoflowInherentGroupService autoflowInherentGroupService;

	@PostMapping("/autoflow/inherent/group/add")
	@ApiOperation("新增固有字段分组")
	public R add(@RequestBody @Valid AutoflowInherentGroupAddReq param) {
		AutoflowInherentGroup obj = autoflowInherentGroupService.add(param);
		return R.success(obj);
	}

	@PostMapping("/autoflow/inherent/group/del")
	@ApiOperation("删除固有字段分组")
	public R del(@RequestBody @Valid AutoflowInherentGroupIdsReq idList) {
		autoflowInherentGroupService.del(idList);
		return R.success();
	}

	@GetMapping("/autoflow/inherent/group/all")
	@ApiOperation("固有字段分组列表")
	public R<List<AutoflowInherentGroup>> all() {
		List<AutoflowInherentGroup> list = autoflowInherentGroupDao.list();
		return R.success(list);
	}

}
